const qiniuUploader = require("./js/qiniuUploader");

let qiniuUpload = (qiniuData) =>{
	/**
	 * 七牛上传图片
	 */
	let filePath = qiniuData.filePath;	//文件对象
	let success = qiniuData.callback.success
	let fail = qiniuData.callback.fail
	let options = {
	  region: 'NCN',
	  domain: qiniuData.url,	//七牛云url域名
	  key: qiniuData.key, 		//文件上传七牛云key名称
	  uptoken: qiniuData.totoken, 	//七牛云后台token
	  uptokenFunc: function() {return '[yourTokenString]';}
	}
	let progress = (res) => {
 		if(qiniuData.progress)qiniuData.progress(res); //
	}
	let cancelTask =  () => {
		// 取消上传
	}	
	let before =() => {
		// `before` 上传前执行的操作
	} 	
	let complete = qiniuData.callback.complete //都会执行
	qiniuUploader.upload(filePath, success, fail, options, progress, cancelTask, before, complete)
}

module.exports = qiniuUpload